<?php

class Utils  {

   public static function findPlayerName($players, $id) {
      $name = "";
      
      foreach($players as $player) {
          if ($player->id == $id) {
              $name = $player->name;
          }
      }
      
      return $name;
      
   }
   
   public static function findFlagName($flags, $id) {
      $name = "";
      
      foreach($flags as $flag) {
          if ($flag->id == $id) {
              $name = $flag->acronym;
          }
      }
      
      return $name;
      
   }            

   public static function isDate($date) {       
      //match the format of the date
      if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $date, $parts))
      {
        //check weather the date is valid of not
            if(checkdate($parts[2],$parts[3],$parts[1]))
              return true;
            else
             return false;
      }
      else
        return false;
   }


}
?>
